#include<boost/asio.hpp>
#include<iostream>
#include<unistd.h>
namespace asio = boost::asio;
using tcp=asio::ip::tcp;
int main(int argc, char const *argv[])
{
    try
    {
    asio::io_context io;
    tcp::resolver::query query("127.0.0.1","8000");
    tcp::resolver resolver(io);
    tcp::resolver::iterator it =resolver.resolve(query);
    tcp::socket socket(io);
    
        socket.connect(it->endpoint());
        while (true)
        {
            std::string str;
            std::cin>>str;
            if(str=="quit")break;
            socket.send(asio::buffer(str));
            socket.receive(asio::buffer(str));
            std::cout<<str<<std::endl;            
        }
        io.run();  
    }catch(boost::system::system_error e)
    {
        std::cout<<e.what()<<std::endl;
    }
    return 0;

}